<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use \dmstr\bootstrap\Tabs;
use yii\helpers\StringHelper;
use kartik\file\FileInput;
use \trntv\filekit\widget\Upload;
use kartik\date\DatePicker;
use yii\redactor;
use chenkby\region;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ButtonDropdown;
/**
* @var yii\web\View $this
* @var yiike\company\model\TtycStore $model
* @var yii\widgets\ActiveForm $form
*/

?>

<div class="ttyc-store-form">

    <?php $form = ActiveForm::begin([
    'id' => 'TtycStore',
    'layout' => 'horizontal',
    'enableClientValidation' => true,
    'errorSummaryCssClass' => 'error-summary alert alert-danger',
    'fieldConfig' => [
             'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
             'horizontalCssClasses' => [
                 'label' => 'col-sm-2',
                 #'offset' => 'col-sm-offset-4',
                 'wrapper' => 'col-sm-8',
                 'error' => '',
                 'hint' => '',
             ],
         ],
    ]
    );
    ?>

    <div class="">
        <?php $this->beginBlock('main'); ?>

        <p>
			<!-- attribute top -->
			<?= $form->field($model, 'top')->radioList(['0'=>'否','1'=>'是'],['class'=>'label-group'])->label('商家推荐'); ?>

			<?= $form->field($model, 'checked')->radioList(['0'=>'未审核','1'=>'已审核'],['class'=>'label-group'])->label('是否审核'); ?>

			<!-- attribute status -->
			<?= $form->field($model, 'status')->radioList(['0'=>'隐藏','1'=>'显示'],['class'=>'label-group'])->label('显示状态'); ?>

			<!-- attribute title -->
			<?= $form->field($model, 'title')->textInput(['maxlength' => true])->label('商家名称') ?>
			<!-- attribute logo -->
			<?=
			$form->field($model, 'logo_file')->label('logo')->widget(
					Upload::className(), [
							'url'              => ['/files/upload'],
							'sortable'         => true,
							'maxFileSize'      => 10000000, // 10 MiB
							'maxNumberOfFiles' => 1,

					]
			);
			?>

			<!-- attribute images -->
			<?=
			$form->field($model, 'imagearr')->label('轮播图')->widget(
					Upload::className(), [
							'url'              => ['/files/upload'],
							'multiple' => true,
							'sortable'         => true,
							'maxFileSize'      => 10000000, // 10 MiB
							'maxNumberOfFiles' => 4,


					]
			);
			?>


			<?= $form->field($model, 'ccate')->dropDownList($category)?>

			<?= $form->field($model, 'starttime')->textInput()->label('开门时间') ?>
			<?= $form->field($model, 'endtime')->textInput()->label('打烊时间') ?>
            <!-- attribute starttime -->

            <!--<?=
            $form->field($model, 'starttime')->label('开始时间')->widget(
                DatePicker::classname(), [
                    'options' => ['placeholder' => ''],
                    'pluginOptions' => [
                        'autoclose' => true,
                        'todayHighlight' => true,
                        'format' => 'yyyy-mm-dd',
                    ]
                ]
            );
            ?>
            -->
            <!-- attribute services -->
            <?= $form->field($model, 'services')->textInput(['maxlength' => true]) ?>

            <!-- attribute consume -->
            <?= $form->field($model, 'consume')->textInput(['maxlength' => true]) ?>

            <!-- attribute level -->
			<?=  $form->field($model, 'level')->dropDownList(['1'=>'★','2'=>'★★','3'=>'★★★','4'=>'★★★★','5'=>'★★★★★']);
            ?>

            <!-- attribute tel -->
            <?= $form->field($model, 'tel')->textInput(['maxlength' => true]) ?>

            <?php echo $form->errorSummary($model); ?>
            <?=
            $form->field($model, '地区')->widget(\chenkby\region\Region::className(),[
                'model'=>$model,
                'url'=> \yii\helpers\Url::toRoute(['get-region']),
                'province'=>[
                    'attribute'=>'province',
                    'items'=> \common\models\Region::getRegion(),
                    'options'=>['class'=>'form-control form-control-inline','prompt'=>'选择省份']
                ],
                'city'=>[
                    'attribute'=>'city',
                    'items'=>\common\models\Region::getRegion($model['province']),
                    'options'=>['class'=>'form-control form-control-inline','prompt'=>'选择城市']
                ],
                'district'=>[
                    'attribute'=>'district',
                    'items'=>\common\models\Region::getRegion($model['city']),
                    'options'=>['class'=>'form-control form-control-inline','prompt'=>'选择县/区']
                ]
            ]);
            ?>

            <!-- attribute address -->
            <?= $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
            <!-- attribute lat -->
            <?= $form->field($model, 'lat')->textInput(['maxlength' => true]) ?>

            <!-- attribute lng -->
            <?= $form->field($model, 'lng')->textInput(['maxlength' => true]) ?>

            <!-- attribute commission_rate -->
            <?= $form->field($model, 'commission_rate')->textInput()->label('红包让利') ?>

            <!-- attribute displayorder -->
            <?= $form->field($model, 'displayorder')->textInput()->label('排序') ?>


            <!--商家描述-->
            <?= $form->field($model, 'description')->widget(\yii\redactor\widgets\Redactor::className(), [
                'clientOptions' => [
                    'lang' => 'zh_cn',
                    'label'=>'描述',
                    'attribute'=>'描述',
                    'plugins' => ['clips', 'fontcolor','imagemanager']
                ]
            ])?>
        </p>

        <?php $this->endBlock(); ?>


        <?=
    Tabs::widget(
                 [
                    'encodeLabels' => false,
                    'items' => [ 
                        [
    'label'   => Yii::t('models', '商家'),
    'content' => $this->blocks['main'],
    'active'  => true,
],
                    ]
                 ]
    );
    ?>
        <hr/>

        <?php echo $form->errorSummary($model); ?>

        <?= Html::submitButton(
        '<span class="glyphicon glyphicon-check"></span> ' .
        ($model->isNewRecord ? '添加' : '保存'),
        [
        'id' => 'save-' . $model->formName(),
        'class' => 'btn btn-success'
        ]
        );
        ?>

        <?php ActiveForm::end(); ?>
    </div>
<script>




</script>

</div>

